<?php
if (count($_POST)) {
    $name = urlencode($_POST['name']);
    $maxsize = 1024*($_POST['size']?$_POST['size']:99999999999999999999999999);
    
    $files = scandir('./result/');
    foreach ($files as $file) if (!is_dir('./result/'.$file)) unlink('./result/'.$file);
    
    $files = scandir('./include/');
    foreach ($files as $file) if (!is_dir('./include/'.$file)) {
        copy('./include/'.$file,'./result/'.$file);
        chmod('./result/'.$file,0666);
    }
    
    require_once('lib.php');
    if ($_POST['advanced']) {
        $projectdir = './advanced/';
        $repodir = './result/';
        require_once('advanced.php');
    } else {
        $projectdir = './simple/';
        $repodir = './result/';
        require_once('simple.php');
    }
} else {?>
<html>
<head><title>Packager!</title>

</head>
<body>
<h1>Packager!</h1>

<form action="" method="post">
    <label for="name">Project Name &amp; Version</label> <input type="text" name="name" id="name" value="ComicCMS_0.2" /><br />
    <label for="size">Max filesize (kb)</label> <input type="text" name="size" id="size" value="330" /><br />
    <p>So, do you want to package from <input type="submit" value="simple" name="simple" /> or <input type="submit" value="advanced" name="advanced" />?</p>
    <p>You must have already <a href="compile.php">compiled download.php</a></p>
</form>
</body>
</html>
<?php } ?>